<template>
  <section class="work-order-item">
    <div class="card-item">
      <div class="title-box" @click="goEdit()">
        <span class="tit">{{itemObj.orderNumber}}</span>
        <span class="status status0" v-if="itemObj.state === 0">创建</span>
        <span class="status status1" v-if="itemObj.state === 1">生效</span>
        <span class="status status2" v-if="itemObj.state === 2">完成</span>
        <span class="status close" v-if="itemObj.state === 3">关闭</span>
        <span class="status close" v-if="itemObj.state === 4">取消</span>
      </div>
      <div class="order-content" @click="goEdit()">
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">日期:</span>
          <span class="value">2025-02-07</span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">生产车间:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">物料编码:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">物料名称:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">规格型号:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">申请数量:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">实发数量:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">仓库:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">总成本:</span>
          <span class="value"></span>
        </div>
        <div class="order-detail-box" v-if="isToggle">
          <span class="label">库存状态:</span>
          <span class="value"></span>
        </div>
      </div>
      <div class="order-bottom-box">
        <div class="toggle-wrap" @click="toggle">
          <span class="txt">{{ isToggle ? '收起' : '展开'}}</span>
          <span class="img">
            <img v-if="isToggle" src="@/assets/images/up-icon.png" alt="" />
            <img v-else src="@/assets/images/down-icon.png" alt="" />
          </span>
        </div>
        <div class="btn-wrap">
          <!-- 按钮组 -->
          <slot name="buttonGorup"></slot>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
// import MaterialContent from "./MaterialContent.vue";
export default {
  name: 'ListItem',
  components: {
    // MaterialContent,
  },
  props: {
    itemObj: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      isToggle:true
    }
  },
  watch:{
    'itemObj':function(){
      this.isToggle = this.itemObj.isToggle
    }
  },
  mounted() {

  },
  methods: {
    goEdit() {
      this.$emit('toEdit')
    },
    goDetail(data) {
      let params = encodeURIComponent(JSON.stringify(data))
        this.$router.push('/allocationDetail?type=list'+'&data='+params)
    },
    toggle() {
      this.isToggle = !this.isToggle
    }
  }
}
</script>

<style lang="scss" scoped>
.work-order-item {
  width: 100%;
  background: #ffffff;
  box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.16);
  border-radius: 4px;
  margin-bottom: 12px;
  .card-item {
    .title-box {
      height: 40px;
      padding: 0 15px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 16px;
      color: #333333;
      font-weight: bold;
      .status {
        color: #333333;
          // display: inline-block;
          font-size: 14px;
          font-size: 12px;
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          // height: 20px;
          border-radius: 4px 4px 4px 4px;
          padding: 2px;
        &.status0 {
          color: #1890ff;
          background: #deebff;
        }
        &.status1 {
          color: #03e2e2;
          background: #d5f8f8;
          // &.close {
        }

        &.status2 {
          color: #52c41a;
          background: #dcffcb;
        }
      }
    }
    .order-content{
      margin: 0 7px;
      padding: 0 9px 8px;
      border-top: 1px #F3F3F3 solid;
      border-bottom: 1px #F3F3F3 solid;
    }
    .order-detail-box {
      display: flex;
      justify-content: space-between;
      // align-items: center;
      font-size: 14px;
      margin-top: 7px;
      .label {
        color: #666666;
      }
      .value {
        color: #333333;
        margin-left: 40px;
        flex: 1;
        text-align: right;
      }
      img {
        width: 18px;
        height: 15px;
      }
    }
  }
  .order-bottom-box {
    height: 52px;
    padding: 0 18px 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .toggle-wrap{
      color: #999999;
      font-size: 14px;
      display: flex;
      align-items: center;
      .img{
        width: 11px;
        height: 13px;
        display: inline-block;
        margin-left: 4px;
        margin-top: 3px;
        img{
          width: 100%;
          height: 100%;
        }
      }
    }
    .btn-wrap{
      display: flex;
      .btn{
        width: 64px;
        height: 32px;
        border: 1px #4286F5 solid;
        border-radius: 4px;
        margin-left: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        color: #4286F5;
        &.btn-01{
          background: #4286F5;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
